import { defHttp } from '/@/utils/http';

export function getMenusApi(params: any) {
  return defHttp.get<any>({ url: '/api/menus', params }, { joinParamsToUrl: true });
}

export function addMenuApi(params: any) {
  return defHttp.post<any>({ url: '/api/menus', params });
}

export function editMenuApi(params: any) {
  return defHttp.put<any>({ url: '/api/menus', params });
}

export function delMenuApi(ids: any) {
  return defHttp.delete<any>({ url: '/api/menus', params: ids });
}

export function getMenusLazyApi(params: any) {
  return defHttp.get<any>({ url: '/api/menus/lazy', params }, { joinParamsToUrl: true });
}

export function buildMenusApi() {
  return defHttp.get<any>({ url: '/api/menus/build' });
}

export function getChild(params: any) {
  return defHttp.get<any>({ url: '/api/menus/child', params }, { joinParamsToUrl: true });
}

export function getMenuSuperiorApi(ids: number[]) {
  const data = ids.length || ids.length === 0 ? ids : Array.of(ids);
  return defHttp.post<any>({ url: '/api/menus/superior', data });
}
